import util from "/common/js/util.js";

Component({
  mixins: [],
  data: {
    customBodyVisible: false,
    tagData: [

    ],
    rangeText:[],//用于显示可选日期范围
    date_value: ""
  },
  props: {
    tagData: [],
    rangeText:[],//用于显示可选日期范围
    data_type: 1,//选择日历类型 1缺卡 2提前读书
    onSubmitFn: function onSubmitFn(e) {}

  },
  didMount() {
    this.initFn()
  },
  didUpdate() {},
  didUnmount() {},
  methods: {
    initFn() {
      this.setData({
        tagData: this.props.tagData
      })
      if(this.props.data_type){
        this.setData({
          data_type:this.props.data_type
        })
      }
      if(this.props.rangeText.length>0){
        this.setData({
          rangeText:this.props.rangeText
        })
      }
    },
    handleOpen() {
      this.setData({
        customBodyVisible: true
      })
    },
    handleClose() {
      this.setData({
        customBodyVisible: false
      })
    },
    onSelect(e) {
      // console.log("---onSelect::",e);
      this.setData({
        date_value: e
      })
    },
    onSubmitFn() {
      let date_value = this.data.date_value;
      if (!date_value) {
        util.message("还未选择日期!");
        return false;
      }
      this.props.onSubmitFn(date_value);
      this.onCancel();
    },
    onCancel() {
      this.setData({
        date_value: ""
      })
      this.handleClose()
    }
  },
});